﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class foother_uc_foother : DAO.ESWebUserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        InitializeUI();
        if (!Page.IsPostBack)
            LoadData();
    }

    protected override void InitializeUI()
    {
        long langId = DAO.Connection.DEFAULT_LANGUAGE;
        if (Session["language"] != null)
            long.TryParse(Session["language"].ToString(), out langId);

        this.LangId = Convert.ToInt32(langId);
    }

    private void LoadData()
    {
        using (SqlConnection conn = new SqlConnection(DAO.Connection.CONN_STRING1))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand("SELECT * FROM dbo.Fn_GetAllBanners() WHERE isActive='true' and position='false'", conn))
            {
                SqlDataReader dr = null;
                dr = cmd.ExecuteReader();
                if (dr != null)
                {
                    int itt = 0;
                    while (dr.Read())
                    {
                        //LiteralControl l = new LiteralControl();
                        phBanners.Controls.Add(new LiteralControl("<div style='float:left'><a target='_blank' href='http://" + dr["link"].ToString() + "'><img style='margin:5px;'"
                            + " src='images/banners/" + dr["id"].ToString() + "_" + dr["filename"].ToString() + "' border='0' /></div>"));
                        if (itt == 0)
                        {
                            phBanners.Controls.Add(new LiteralControl("<div style='clear:both;'><a style='font-size:13px;font-weight:bold;padding-left:7px'>Partner Organization:</a></div>"));
                            phBanners.Controls.Add(new LiteralControl("<div style='clear:both'></div>")); itt++;
                        }
                    }
                }
                dr.Close();
            }
        }
    }
}
